func searchInsert(nums []int, target int) int {
    n := len(nums)
    left, right := 0, n-1
    ans :=n
    for left <= right{
        middle := (right - left) >> 1 + left
        if nums[middle] >= target {
            ans = middle
            right = middle - 1
        } else {
            left = middle + 1
        }
    }
    return ans
}